package routers

import (
	"go_web_bubble/controller"
	"go_web_bubble/setting"

	"github.com/gin-gonic/gin"
)

func SetupRouter() *gin.Engine {
	if setting.Conf.Release {
		gin.SetMode(gin.ReleaseMode) //三种模式：debug、release、test
	}
	r := gin.Default()
	r.Static("/static", "static")
	r.LoadHTMLGlob("templates/*")
	r.GET("/", controller.IndexHandler)

	//v1路由组设置
	v1Group := r.Group("v1")
	{
		//添加待办事项
		v1Group.POST("/bubble", controller.CreateBubble)
		//查看所有待办事项
		v1Group.GET("/bubble", controller.GetAllBubble)
		// 修改某一个待办事项
		v1Group.PUT("/bubble/:id", controller.UpdateBubble)
		//删除一个待办事项
		v1Group.DELETE("/bubble/:id", controller.DeleteBubble)
	}
	return r
}
